/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			defvar.h
  \date			Dec 2011
  \author		TNick

  \brief		Contains the definition for DefVar class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __DEFVAR_INC__
#define __DEFVAR_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<qglobal.h>
#include	<QChar>
#include	<QStringList>
#include	<QSettings>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	PgSave		{

class		IPgSave;

}


namespace	PgScr	{

class	VarStore;

/**
*	@brief	 class representing the storage space for a custom variable
*
*/
class DefVar				{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/**
	*	@brief	get a string representation of the object / variable
	*/
	virtual QString				presentation	( VarStore * uv = NULL ) = 0;


	/**
	*	@brief	resetContent resets the variable and frees any resources
	*
	*	The variable is brought to the ground state ( integer 0 ).
	*/
	virtual void				resetContent	( VarStore * uv = NULL ) = 0;


	/**
	*	@brief	set default value
	*
	*	This is a low level functino that does NOT perform a resetContent()
	*	nor does it set the type that is assumed to already be the right one.
	*/
	virtual void				setDefault		( VarStore * uv = NULL ) = 0;


	/**
	*	@brief	describes in a short string the type of undelying storage
	*
	*/
	virtual QString				typeName		( VarStore * uv = NULL ) = 0;


	/**
	*	@brief	tell if this type of variable may be saved (is saveable)
	*
	*	@return	true if variable can be saved, false otherwise
	*/
	virtual bool				canSave			( VarStore * uv = NULL ) = 0;


	/**
	*	@brief	save the content of the variable
	*
	*	The variable is saved as a group at current path. The name of the
	*	group is given by the name of the variable and, inside, the type and
	*	actual value are saved using \b TAG_NAME_TYPE and \b TAG_NAME_VALUE.
	*
	*	@return	true if variable was saved, false otherwise

	*/
	virtual bool				save			(
			PgSave::IPgSave &		stg,
			VarStore *				uv = NULL
			) = 0;


	/**
	*	@brief	load the content of the variable
	*
	*	The variable is saved as a group at current path. The name of the
	*	group is given by the name of the variable and, inside, the type and
	*	actual value are saved using \b TAG_NAME_TYPE and \b TAG_NAME_VALUE.
	*
	*	@return	true if variable was loaded, false otherwise
	*/
	virtual bool				load			(
			PgSave::IPgSave &		stg,
			VarStore *				uv = NULL
			) = 0;




	/** @name Retrieving common values
	*
	*/
	//@{

	virtual bool				convToBool		(
			bool 	*		b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual qint16				convToShort		(
			bool 	*		b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual qint32				convToInt		(
			bool 	*		b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual qint64				convToLong		(
			bool 	*		b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual qint8				convToByte		(
			bool 	*		b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual qreal				convToDouble	(
			bool 	*		b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual QStringList			convToStrLst	(
			bool *			b_ok,
			VarStore *		uv = NULL
			) = 0;

	virtual QString				convToStr		(
			bool *			b_ok,
			VarStore *		uv = NULL
			) = 0;


	//@}


public:

	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class DefVar	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace	PgScr

#endif // __DEFVAR_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
